package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.zx.kitchen.index.common.entity.IndexOrderBean;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.NewBusinessModelImpl;
import com.zx.kitchen.index.common.mvp.view.NewBusinessView;

import java.util.List;

/**
 * Created by Administrator on 2017/3/6.
 */

public class NewBusinessPresenter implements OnResultListener {
    private NewBusinessModelImpl newBusinessModel;
    private NewBusinessView newBusinessView;
    private Context context;

    public NewBusinessPresenter(NewBusinessView newBusinessView, Context context) {
        this.newBusinessView = newBusinessView;
        this.context = context;
        newBusinessModel = new NewBusinessModelImpl();
    }

    public void getFromNet() {
        newBusinessModel.getFromNet(1, context, this, null);
    }

    @Override
    public void onSuccess(int requestCode, String str) {
        //解析JSON数据
        IndexOrderBean  orderBean = newBusinessModel.asyncJson(str);
        //显示到界面上
        newBusinessView.onSuccess(orderBean);
    }


    @Override
    public void onFailure(int requestCode, String str) {
        newBusinessView.onFail(str);
    }
}
